<%@page pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>H+ 后台主题UI框架 - 基础表格</title>

    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">


<jsp:include page="/layout/css.jsp"/>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/plugins/bootstrap-table/bootstrap-table.min.css">

<link href="${pageContext.request.contextPath}/css/plugins/iCheck/custom.css" rel="stylesheet">


</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>基本</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="table_basic.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="table_basic.html#">选项1</a>
                                </li>
                                <li><a href="table_basic.html#">选项2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table id="table"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <jsp:include page="/layout/script.jsp"/>
    <script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table-filter-control.js"></script>

    <!-- Peity -->
    <script src="${pageContext.request.contextPath}/js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="${pageContext.request.contextPath}/js/content.js?v=1.0.0"></script>


    <!-- iCheck -->
    <script src="${pageContext.request.contextPath}/js/plugins/iCheck/icheck.min.js"></script>

    <!-- Peity -->
    <script src="${pageContext.request.contextPath}/js/demo/peity-demo.js"></script>
    <script>
        $('#table').bootstrapTable({
            url:'${pageContext.request.contextPath}/RepairServlet/listByName?name='+${owner.ownerId},
            pagination:true,
            pageSize:5,
            pageList:[5,10,'All'],
            search:true,
            showColumns:true,
            showRefresh:true,
            columns: [{
                checkbox:true
            },{
                field: 'ownerId',
                title: '用户编号',
            },{
                field: 'repairPhone',
                title: '电话',
            },{
                field: 'repairAddr',
                title: '地址',
            },{
                field: 'repairState',
                title: '维修状态',
            },{
                field: 'repairCreatetime',
                title: '报修日期',
            },{
                field: 'repairEndtime',
                title: '完工日期',
            },{
                field: 'repairContents',
                title: '维修内容',
            },{
                field: 'repairPleased',
                title: '满意度',
            },{
                field: 'serviceAssess',
                title: '服务评价',
            },{
                field: 'employeeId',
                title: '维修工id',
            },{
                title:'操作',
                formatter:'czFormatter',
                events:'operateEvents'
            }],
            rowStyle:function(row,index){
                if (index % 2 == 0) {
                    return {
                        classes: 'success'
                    };
                }else{
                    return {
                        classes: 'default'
                    };
                }
                return {};
            }
        });
        function czFormatter(row,index){
            return [
                '<div>',
                '<a class="edit" href="javascript:void(0)" title="edit">',
                '<i class="glyphicon glyphicon-pencil"></i>',
                '</a>&nbsp;&nbsp;&nbsp;&nbsp;',
                '</div>'
            ].join('');
        }
        window.operateEvents={
            'click .edit':function(e,value,row){
                $('#test [name=ownerId]').val(row['ownerId']);
                $('#test [name=repairPhone]').val(row['repairPhone']);
                $('#test [name=repairAddr]').val(row['repairAddr']);
                $('#test [name=repairState]').val(row['repairState']);
                $('#test [name=repairCreatetime]').val(row['repairCreatetime']);
                $('#test [name=repairEndtime]').val(row['repairEndtime']);
                $('#test [name=repairContents]').val(row['repairContents']);
                $('#test [name=repairPleased]').val(row['repairPleased']);
                $('#test [name=serviceAssess]').val(row['serviceAssess']);
                $('#test [name=employeeId]').val(row['employeeId']);
                //测试时丢了传id
                $('#test [name=repairId]').val(row['repairId']);

                inde = layer.open({
                    type:1,
                    content:$('#test'),
                    area:['480px','430px']
                });
            }
        };
        //放在$(function( 内部 ))  相当于加载全页面   window.onload
        $(function () {
            $('#sub').click(function(){
                $.post('${pageContext.request.contextPath}/RepairServlet/updateById',$('form').serialize(),function (r) {
                    if(r){
                        layer.msg('修改成功');
                        //关闭弹层
                        layer.close(inde);
                        //刷新表格
                        $('#table').bootstrapTable('refresh');
                    }else{
                        layer.msg('修改失败');
                    }
                });
            });
        });
    </script>

</body>
<div class="row" id="test" style="display: none">
    <div class="col-sm-12" >
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>简单示例</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="form_basic.html#">选项1</a>
                        </li>
                        <li><a href="form_basic.html#">选项2</a>
                        </li>
                    </ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal m-t">
                    <input type="hidden" name="repairId">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">用户编号：</label>
                        <div class="col-sm-8">
                            <input  name="ownerId" readonly minlength="2" type="text" class="form-control" required="" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">电话：</label>
                        <div class="col-sm-8">
                            <input  name="repairPhone" minlength="7" type="text" class="form-control" required="" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维修地址：</label>
                        <div class="col-sm-8">
                            <input  name="repairAddr" minlength="2" type="text" class="form-control" required="" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维修状态：</label>
                        <div class="col-sm-8">
                            <input  name="repairState" readonly minlength="2" type="text" class="form-control"  aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">报修日期：</label>
                        <div class="col-sm-8">
                            <input  name="repairCreatetime"  type="text" class="form-control"  aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">完工日期：</label>
                        <div class="col-sm-8">
                            <input  name="repairEndtime" minlength="2" type="text" class="form-control" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维修内容：</label>
                        <div class="col-sm-8">
                            <input  name="repairContents" minlength="2" type="text" class="form-control" required="" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">满意度：</label>
                        <div class="col-sm-8">
                            <input  name="repairPleased" minlength="1" type="text" class="form-control"  aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">服务评价：</label>
                        <div class="col-sm-8">
                            <input  name="serviceAssess"  type="text" class="form-control" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">维修工id：</label>
                        <div class="col-sm-8">
                            <input  name="employeeId" readonly  minlength="2" type="text"  class="form-control" required="" aria-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-3">
                            <div class="btn btn-primary" id="sub">提交</div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>
</html>